<template>
  <div class="context">
    <span style="display: flex; align-items: center">
      <img
        src="@/assets/logo.png"
        width="48px"
        style="display: inline; margin: 5px 0 0 0; padding: 0 10px 0 0"
      />
      <h1
        style="
          display: inline;
          font-size: 28px;
          line-height: 28px;
          padding: 0;
          margin: 15px 0 0 0;
        "
      >
        OPREC
      </h1>
      <span
        style="
          display: inline;
          opacity: 0.75;
          transform: scale(0.85);
          font-size: 12px;
          font-weight: bolder;
          margin: -5px 0 0 0;
        "
        >4CDAPP</span
      >
    </span>
    <el-popover
      placement="bottom"
      width="250"
      trigger="click"
      v-model="showNavbar"
    >
      <el-button
        icon="el-icon-menu"
        slot="reference"
        circle
        style="margin: 5px 0 0 0"
      ></el-button>
      <!-- <div @click="showNavbar = false" style="padding:15px 0 5px 0"> -->
      <div style="padding: 15px 0 5px 0">
        <span class="login-indicator">
          <div v-if="$store.state.login.status != 0">
            <el-badge is-dot type="info">
              <el-button
                round
                plain
                type="info"
                style="width: 200px"
                @click="
                  $emit('login');
                  showNavbar = false;
                "
              >
                <i class="el-icon-user"></i>
                未登录
              </el-button>
            </el-badge>
          </div>
          <div v-if="$store.state.login.status === 0">
            <el-badge is-dot type="success">
              <el-button
                round
                plain
                type="success"
                style="width: 200px"
                @click="
                  $emit('login');
                  showNavbar = false;
                "
              >
                <i class="el-icon-user-solid"></i>
                {{ $store.state.login.userbase.name }}
              </el-button>
            </el-badge>
          </div>
        </span>
        <el-divider></el-divider>
        <div
          :style="[
            { maxHeight: bodyHeight - 360 + 'px' },
            { overflowY: 'scroll' },
          ]"
        >
          <navbar @selected="showNavbar = false" />
        </div>
      </div>
    </el-popover>
  </div>
</template>

<script>
import navbar from "../Navigation";
export default {
  components: { navbar },
  computed: {
    bodyWidth() {
      return this.$store.state.view.body.size.width;
    },
    bodyHeight() {
      return this.$store.state.view.body.size.height;
    },
  },
  data() {
    return {
      showNavbar: false,
    };
  },
  methods: {},
};
</script>

<style scoped>
.login-indicator {
  text-align: center;
  padding-top: 10px;
}
.context {
  display: -webkit-flex;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
</style>